package com.zgc.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import com.zgc.dao.IUserDao;
import com.zgc.domain.User;
@Repository
public class UserDaoImpl extends HibernateDaoSupport implements IUserDao {
	@Resource
	public void setSF(SessionFactory sessionFactory){
		super.setSessionFactory(sessionFactory);
	}
	public void regist(User user) {
		this.getHibernateTemplate().save(user);
	}
	public User login(String username, String password) {
		User user = new User();
		String hql= " from User u where u.username=? and u.password=? "; 
		List list = this.getHibernateTemplate().find(hql,username,password);
		if (list != null && list.size()>0) {
			user = (User) list.get(0);
			return user;
		}else{
			return null;
		}
		
	}

}
